﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace IMeiWeiWebService.Providers
{
    public class AdProvider
    {
        IMeiWei.BLL.adsetting bll_adsetting = new IMeiWei.BLL.adsetting();
        IMeiWei.BLL.adimgs bll_adImg = new IMeiWei.BLL.adimgs();

        public List<IMeiWei.Model.adsetting> LoadAdSettings(string adType)
        {
            return bll_adsetting.GetModelList(" adType = '" + adType + "'");
        }

        public List<IMeiWei.Model.adimgs> LoadAdImages(string adType)
        {
            var adSettings = bll_adsetting.GetModelList(" adType = '" + adType + "'");
            var adImgs = bll_adImg.GetModelList(" 1=1");

            if (null != adSettings && adSettings.Count > 0 || null != adSettings && adSettings.Count > 0)
            {
                return (from adimg in adImgs 
                       join adSetting in adSettings on adimg.AdSettings_Id equals adSetting.Id
                       select adimg).ToList();
            }

            return new List<IMeiWei.Model.adimgs>();
        }

    }
}